/**
 * JAVACC DEMO 1.0
 * @copy right dwusoft company All rights reserved. 
 * @Package com.apache.audit.service.plugins  
 */
package com.apache.audit.service.plugins;

import java.util.List;

import com.apache.api.manager.PluginConnector;
import com.apache.api.vo.ParamsVo;
import com.apache.api.vo.ResultEntity;
import com.apache.audit.entity.LogModel;
import com.apache.audit.manager.LogModelManager;
import com.apache.cache.util.Validator;
import com.apache.database.model.Page;
import com.apache.tools.ClassToolsUtil;

/**
 * description:  日志模型配置信息列表
 * @author dyhou 创建时间：2016-7-11  
 */
public class LogModelListPluginImpl implements PluginConnector {

	private LogModelManager logModelManager;

	/**
	 * TODO 日志模型配置信息列表  
	 */
	public Object execute(ParamsVo param) throws Exception {
		ResultEntity entity = new ResultEntity();
		entity.setResult("true");

		LogModel deal = new LogModel();
		deal = (LogModel) ClassToolsUtil.getInstance().convert2Bean(param.getParams(), deal);
		ParamsVo<LogModel> vo = new ParamsVo<LogModel>();
		vo.setObj(deal);
		vo.setMethodKey("ByService");
		String rows = Validator.getDefaultStr(String.valueOf(param.getParams("rows")), "0");
		if ("0".equals(rows)) {
			List list = logModelManager.getList(vo);
			entity.setEntity(list);
		} else {
			String page = Validator.getDefaultStr(String.valueOf(param.getParams("page")), "1");
			vo.setParams("pageIndex", page);
			vo.setParams("pageSize", rows);
			Page pageList = logModelManager.getPageInfo(vo);
			entity.setEntity(pageList);
		}
		entity.setMessage("查询成功");
		return entity;
	}

	public void setLogModelManager(LogModelManager logModelManager) {
		this.logModelManager = logModelManager;
	}

}
